National Geographic Topo! Waypoint Format. This filter
reads and writes .TPG files created by various editions of NG Topo!
This filter will *not* work with the newer combined .TPO files.
+
+ The option 'datum="datum name"' can be used to override the
+ default of NAD27 ("N. America 1927 mean") which is correct
+ for the continental U.S. Points in Hawaii should use "Old
+ Hawaiian_mean"
+
Contributed by Alex Mottram.
HOLUX
static FILE *tpg_file_in;
static FILE *tpg_file_out;
static void *mkshort_handle;
+static char *tpg_datum_opt;
+static int tpg_datum_idx;
static unsigned int waypt_out_count;
+static
+arglist_t tpg_args[] = {
+ {"datum", &tpg_datum_opt, "Datum (default=NAD27)", "N. America 1927 mean", ARGTYPE_STRING },
+ {0, 0, 0, 0, 0}
+};
+
static int
tpg_fread(void *buff, size_t size, size_t members, FILE * fp)
{
return memcmp(header_bytes, header, len);
}
+static void
+tpg_common_init(void)
+{
+ tpg_datum_idx = GPS_Lookup_Datum_Index(tpg_datum_opt);
+ if (tpg_datum_idx < 0) {
+ fatal(MYNAME ": Datum '%s' is not recognized.\n", tpg_datum_opt);
+ }
+}
+
static void
tpg_rd_init(const char *fname)
{
+ tpg_common_init();
tpg_file_in = xfopen(fname, "rb", MYNAME);
}
static void
tpg_wr_init(const char *fname)
{
+ tpg_common_init();
tpg_file_out = xfopen(fname, "wb", MYNAME);
mkshort_handle = mkshort_new_handle();
waypt_out_count = 0;
&wpt_tmp->latitude,
&wpt_tmp->longitude,
&amt,
- 78);
+ tpg_datum_idx);
wpt_tmp->altitude = elev;
&lat,
&lon,
&amt,
- 78);
+ tpg_datum_idx);
/* swap the sign back *after* the datum conversion */
tpg_read,
tpg_write,
NULL,
- NULL,
+ tpg_args,
CET_CHARSET_ASCII, 0 /* CET-REVIEW */
};